package com.itheima.handle;

import com.itheima.entity.Result;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理
 *
 * @create 2020/12/2 0002 19:14
 */
@RestControllerAdvice
public class GlobalException {
    @ExceptionHandler(Exception.class)
    public Result doEx(Exception e) {
        if (e instanceof AccessDeniedException) {
            return new Result(false, "无访问权限!");
        }
        return new Result(false, "服务器忙,请重试!");
    }
}
